# -- coding: utf-8 --
# file: depends.py
#
import os

# 判断是否已安装requests模块,若没有则下载安装
count = 2
while count:
    try:
        import requests
        print('已检测到requests模块           ok')
        break
    except:
        print('检测到未安装requests模块,现在开始安装......')
        os.system('pip install requests')
        count -= 1
        continue


import sys
version = sys.version_info
v_info = str(version.major) + '.' + str(version.minor) + '.' + str(version.micro)

# 判断Python版本号
if version < (3, 0):
        print('检测到该电脑的Python版本为:' + v_info)
        import ConfigParser as cfps
else:
        print('检测到该电脑的Python版本为:' + v_info)
        import configparser as cfps

# 文件路径
root_dir = os.path.split(os.path.realpath(__file__))[0]
# 配置ini文件路径
config_file_path = os.path.join(root_dir, 'requests.ini')
# 读取配置文件
cf = cfps.ConfigParser()
cf.read(config_file_path)
